package org.jeeasy.ai.utils;

import org.jeeasy.ai.dto.ChatMessageDTO;
import org.jeeasy.ai.enums.ChatMsgType;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.messages.SystemMessage;
import org.springframework.ai.chat.messages.UserMessage;

public class ChatUtil {
    public static String createSessionId() {
        return String.valueOf(System.currentTimeMillis());
    }


    public static Message toChatMessage(ChatMessageDTO messageDTO) {
        ChatMsgType type = ChatMsgType.fromValue(messageDTO.getMessageType());
        if (type == ChatMsgType.SYSTEM) {
            return new SystemMessage(messageDTO.getContent());
        }
        return new UserMessage(messageDTO.getContent());
    }
}
